var _table =null;
$(document).ready(function(){
    // 初始化表格
    initAppOptionFeedbackTable();
    
    $("#btn-advanced-search").click(function(){
		 refulsh();
	  });
});



var userManage = {
    getQueryCondition : function(data) {
        var param = {};

        param.datemin = $("#datemin").val();
        param.datemax = $("#datemax").val();
        param.param = $("#param").val();

        //组装分页参数
        param.page = data.start;
        param.rows = data.length;
        return param;
    },
}

/*管理员-修改新增*/
function data_edit(title,url,w,h){
	layer_show_callback(title,url,w,h,function(){
		refulsh();
	});
}


function refulsh(){
	userManage.fuzzySearch = false;
    _table.draw();
}



function initAppOptionFeedbackTable(){
	  var $table = $('#table-user');
	    _table = $table.dataTable($.extend(true,{},CONSTANT.DATA_TABLES.DEFAULT_OPTION, {
		 orderMulti: false, //启用多列排序
		 bFilter: false,//去掉搜索框  
		 order: [], //取消默认排序查询,否则复选框一列会出现小箭头
		 renderer: "bootstrap", //渲染样式：Bootstrap和jquery-ui
		 pagingType: "simple_numbers", //分页样式：simple,simple_numbers,full,full_numbers
		 aaSorting: [[ 1, "desc" ]],//默认第几个排序
		 bStateSave: true,//状态保存
			pageLength:10,
			lengthMenu:[10,20,50,100],
			iDisplayLength: 10,
	        ajax : function(adata, callback, settings) {//ajax配置为function,手动调用异步查询
	            //封装请求参数
	           var param = userManage.getQueryCondition(adata);
	            $.ajax({
	                    type: "post",
	                    url: "queryAppOptionFeedbackPage",
	                    cache : false,  //禁用缓存
	                    data: param,    //传入已封装的参数
	                    dataType: "json",
	                    success: function(reslut) {
                            //封装返回数据，这里仅演示了修改属性名
                            var returnData = {};
                            returnData.draw = adata.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = reslut.data.total;
							returnData.recordsFiltered = reslut.data.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = reslut.data.list;
							$("#total").text(reslut.data.total);
                            callback(returnData);
	                    },
	                    error: function(XMLHttpRequest, textStatus, errorThrown) {
	                       console.log("查询失败");
	                    }
	                });
	        },
    "columns": [
				 {"data":  function ( row, type, set ) {//属性方法可以自定义显示方式
	             return  '<input type="checkbox" class="iCheck" value='+row.id+'>';        
	         },"bSortable":false},
				{
					 "data": "aofContext","bSortable": false
				},
				{
					 "data": "aofRestypeName","bSortable": false
				},
				{
					 "data": "aofStatusName","bSortable": false
				},
				{
					 "data": "aofBackContext","defaultContent": "","bSortable": false
				},
				{
					 "data": "creater","bSortable": false
				},
				{
					 "data": "gmtCreate","bSortable": false
				},
				{
					 "data": "modifier","defaultContent": "","bSortable": false
				},
				{
					 "data": "gmtModified","defaultContent": "","bSortable": false
				}
     ],
     "columnDefs": [
         {
             "targets": [9], // 目标列位置，下标从0开始
             "data": "id", // 数据列名
             "render": function(data, type, full) { // 返回自定义内容
            	 var str ="";
            	 str =str+'<a title="编辑" href="javascript:void(0);" onclick="data_edit(\'意见回复\',\'initAddUpdateAppOptionFeedbackPage?id='+data+'\',\'500\',\'400\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>回复</a> ';
            	 return str;
             }
         }
     ]
	 })).api();   
};
   
